An electronic device may include a processor that executes a variety of different programs or applications to automatically perform various functionalities. The electronic device may further include storage components such as a disk drive that enables data to be stored in a general manner and a Random Access Memory (RAM) that enables the applications to request an allocation of the RAM for temporary use while the application is being executed. For example, when the application requires to temporarily store some data during execution, the application may dynamically request the allocation of a chunk from the RAM. The request for this allocation may be included as a call to a function which is itself defined by one or more lines within the code of the application. Furthermore, during the course of the application being executed, there may be a plurality of calls to this or similar memory application programming interface functions from the application that request the allocation of RAM. In addition, further applications may be executed concurrently that may also request the allocation of RAM.
Because the RAM is a limited resource, the code of the application may further include code that releases the allocated RAM when there is no further need for the temporary requirement of the allocation. The application requesting the allocation of RAM is therefore responsible for freeing or releasing the allocated RAM upon completion of its use so that the RAM does not run out or remain pending in a low-resource state which may result in adverse effects for the electronic device and the applications being executed (e.g., application crash, system crash, slow processing, etc.). When the allocated RAM is not ultimately released, this is defined as a memory leak where the allocated chunk is not being used by the application but where the device or other applications do not have access to this allocated chunk.
The longer the application with the memory leak continues to run, the more likely that memory leaks will accumulate in this time period that eventually causes the RAM to run out. One possible response is to reboot the electronic device that effectively frees all allocated RAM. However, upon another execution of the application with the memory leak, the memory leaks may again accumulate. Thus, a more permanent response is to review the lines of code of the application to determine the cause for the memory leak. Conventionally, this process is performed manually where the user simply goes line by line in the code. However, those skilled in the art will understand that the code of the application may include thousands or millions of lines of code.